﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace lcps.Web.supplyplan
{
    public partial class Add : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
                       
        }

        		protected void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtxh.Text.Trim().Length==0)
			{
				strErr+="xh不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtplandate.Text))
			{
				strErr+="plandate格式错误！\\n";	
			}
			if(this.txtprojectname.Text.Trim().Length==0)
			{
				strErr+="projectname不能为空！\\n";	
			}
			if(this.txtprojectid.Text.Trim().Length==0)
			{
				strErr+="projectid不能为空！\\n";	
			}
			if(this.txtwbs.Text.Trim().Length==0)
			{
				strErr+="wbs不能为空！\\n";	
			}
			if(this.txtxyunit.Text.Trim().Length==0)
			{
				strErr+="xyunit不能为空！\\n";	
			}
			if(this.txtmateruser.Text.Trim().Length==0)
			{
				strErr+="materuser不能为空！\\n";	
			}
			if(this.txtprojectunit.Text.Trim().Length==0)
			{
				strErr+="projectunit不能为空！\\n";	
			}
			if(this.txtprojectmajor.Text.Trim().Length==0)
			{
				strErr+="projectmajor不能为空！\\n";	
			}
			if(this.txtplannum.Text.Trim().Length==0)
			{
				strErr+="plannum不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtplanoverdate.Text))
			{
				strErr+="planoverdate格式错误！\\n";	
			}
			if(this.txtaddplannum.Text.Trim().Length==0)
			{
				strErr+="addplannum不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			string xh=this.txtxh.Text;
			DateTime plandate=DateTime.Parse(this.txtplandate.Text);
			string projectname=this.txtprojectname.Text;
			string projectid=this.txtprojectid.Text;
			string wbs=this.txtwbs.Text;
			string xyunit=this.txtxyunit.Text;
			string materuser=this.txtmateruser.Text;
			string projectunit=this.txtprojectunit.Text;
			string projectmajor=this.txtprojectmajor.Text;
			string plannum=this.txtplannum.Text;
			DateTime planoverdate=DateTime.Parse(this.txtplanoverdate.Text);
			string addplannum=this.txtaddplannum.Text;

			lcps.Model.supplyplan model=new lcps.Model.supplyplan();
			model.xh=xh;
			model.plandate=plandate;
			model.projectname=projectname;
			model.projectid=projectid;
			model.wbs=wbs;
			model.xyunit=xyunit;
			model.materuser=materuser;
			model.projectunit=projectunit;
			model.projectmajor=projectmajor;
			model.plannum=plannum;
			model.planoverdate=planoverdate;
			model.addplannum=addplannum;

			lcps.BLL.supplyplan bll=new lcps.BLL.supplyplan();
			bll.Add(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","add.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
